
package com.zhu.salesmanagement;

import com.zhu.salesmanagement.common.Actions;
import com.zhu.salesmanagement.views.SyncView;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;

/**
 * 同步界面
 */

public class SyncActivity extends Activity {

    private SyncView mSyncView = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        LayoutInflater mInflater = getLayoutInflater();
        mSyncView = (SyncView) mInflater.inflate(R.layout.main_sync, null);
        setContentView(mSyncView);

        initData();
    }

    /**
     * 初始化数据
     */
    private void initData() {
        mSyncView.initData(this);
    }

    /**
     * 按键事件拦截
     */
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (mSyncView.isSync()) {
            return true;
        }
        return super.dispatchKeyEvent(event);
    }

    /**
     * 触摸事件拦截
     */
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (mSyncView.isSync()) {
            return true;
        }
        return super.dispatchTouchEvent(ev);
    }

    public void onResume() {
        super.onResume();
        Actions.setAutoTime(this);
    }

    public void onDestroy() {
    	mSyncView.detory();
        super.onDestroy();
    }
}
